package com.api.oa.mapper;

import com.api.oa.model.entity.YQBanner;
import com.api.oa.model.vo.OaNoticeVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface YQBannerMapper {

    @Insert("insert into  yq_banner  (" +
        "resUrl," +
        "isTop," +
        "isEnable," +
        "bannerRes," +
        "sortTime" +
    ") " +
    "values " +
    "(" +
        "#{entity.resUrl}," +
        "#{entity.isTop}," +
        "#{entity.isEnable}," +
        "#{entity.bannerRes}," +
        "#{entity.sortTime}" +
    ")" )
    @Options(useGeneratedKeys = true, keyProperty = "bannerId", keyColumn = "id")
    Integer insert(@Param("entity") YQBanner entity);



    @Update("update  yq_banner  set " +
        "resUrl = #{entity.resUrl}," +
        "isTop = #{entity.isTop}," +
        "isEnable = #{entity.isEnable}," +
        "bannerRes = #{entity.bannerRes}," +
        "sortTime = #{entity.sortTime}" +
    " where bannerId = #{entity.bannerId}")
    Integer update(@Param("entity") YQBanner  entity);


    @Delete("delete from yq_banner where bannerId=#{id}")
    void delete(@Param("id") Long id);


    @Select("<script> select * from  yq_banner  where 1 = 1 <if test='isEnable!=null and isEnable!=\"\"'>and  isEnable = #{isEnable}</if> </script>")
    List<YQBanner> list(@Param("isEnable") String isEnable);


    @Select("select * from  yq_banner  where bannerId = #{id} limit 1")
    YQBanner findOne(@Param("id") Long id);

}

